﻿namespace ConsoleApp2._1014;
public class Demo
{
    public void TestPrint()
    {
        int[] arr = new int[5];
        arr[0] = 1;
        arr[1] = 2;
        Console.WriteLine(arr[0]);
        Console.WriteLine(arr[1]);
        String[] arr2 = new string[5];
        arr2[0]="aa";
        arr2[1] = "bb";
        Console.WriteLine(arr2[2]);
        String[] arr3 ={"aaa","bbb","ccc"};
        Console.WriteLine(arr3[0]);
        Console.WriteLine(arr3[1]);
        //二维数组
        int[,] arr5 = {{1,2,3},{4,5,6},{7,8,9}};
        Console.WriteLine(arr5[1,1]);
        int[] arr6 = { 11, 7, 88, 31, 99, 9 };
        foreach (var item in arr6)
        {
            Console.WriteLine(item+"\t");
        }
        Array.Sort(arr6);
        Array.Reverse(arr6);//先排序再反转
        Console.WriteLine();
        foreach (var item in arr6)
        {
            Console.WriteLine(item+"\t");
        }
        Console.WriteLine();
    }
    private static void Sort(double[] a)
    {
        double temp;
        for (int i = 0; i < a.Length-1; i++)
        {
            for (int j = 0; j < a.Length - i - 1; j++)
            {
                if (a[i] < a[j + 1])
                {
                    temp = a[j];
                    a[j] = a[j+1];
                    a[j+1] = temp;
                }
            }
        }
    }
}
